package com.telecomyt.jwportal.activity.channel;

import android.content.Context;
import android.content.Intent;
import android.widget.TextView;

import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.telecomyt.jwportal.R;
import com.telecomyt.jwportal.activity.channel.adapter.FixedChannelAdapter;
import com.telecomyt.jwportal.base.BaseActivity;
import com.telecomyt.jwportal.base.BasePresenter;
import com.telecomyt.jwportal.entity.FixedChannel;
import com.telecomyt.jwportal.utils.ToastUtils;
import com.telecomyt.jwportal.widget.FraToolBar;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * @date: 2020/9/27
 * @author: chengDa
 * @description: 固定频道
 */
public class FixedChannelActivity extends BaseActivity {

    List<FixedChannel> list = new ArrayList<>();
    @BindView(R.id.mFraToolBar)
    FraToolBar mFraToolBar;
    @BindView(R.id.mRecyclerView)
    RecyclerView mRecyclerView;
    FixedChannelAdapter mAdapter;
    @BindView(R.id.mTvQuitChannel)
    TextView mTvQuitChannel;

    public static void start(Context context) {
        Intent starter = new Intent(context, FixedChannelActivity.class);
        context.startActivity(starter);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_fixed_channel;
    }

    @Override
    protected void initView() {
        mFraToolBar.setLeftFinish(this);
        for (int i = 0; i < 20; i++) {
            FixedChannel fixedChannel = new FixedChannel();
            fixedChannel.setTitle("张三" + i);
            list.add(fixedChannel);
        }
        mRecyclerView.setLayoutManager(new GridLayoutManager(this, 4));
        mAdapter = new FixedChannelAdapter(list);
        mRecyclerView.setAdapter(mAdapter);
        mAdapter.setOnItemClickListener((adapter, view, position) -> ToastUtils.showShort(position + ""));
    }

    @Override
    protected void initData() {

    }

    @Override
    protected BasePresenter creatPresenter() {
        return null;
    }


    @OnClick(R.id.mTvQuitChannel)
    public void onViewClicked() {
        finish();
    }
}